package com.front.teacher.teacherapp.view.activity;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.widget.Toolbar;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;

import com.front.teacher.teacherapp.R;
import com.front.teacher.teacherapp.base.PermissionsActivity;

import butterknife.ButterKnife;
import butterknife.InjectView;

public class CameraActivity extends PermissionsActivity {
    private SurfaceView surfaceView;
    private SurfaceHolder surfaceHolder;
    @InjectView(R.id.toolbar)
    Toolbar toolbar;
    @InjectView(R.id.fab)
    FloatingActionButton fab;

    @Override
    public void initView() {
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        surfaceView = (SurfaceView) findViewById(R.id.surfaceView_camera);
        surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
            @Override
            public void surfaceCreated(SurfaceHolder holder) {
                surfaceHolder = holder;
            }

            @Override
            public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {

            }

            @Override
            public void surfaceDestroyed(SurfaceHolder holder) {

            }
        });
        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
                setCameraSurfaceHolder(surfaceHolder);
                openCamera();
            }
        });
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_camera;
    }

}
